package o2o.web.actions.map;

import com.jinyou.utils.common.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import map.AMapUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

//高德地图辅助类
@Api(tags = "高德地图工具")
@Controller
public class AMapUtilsAction {


    //获取骑行距离配置
    @ApiOperation("获取两点间导航距离")
    @RequestMapping(method = RequestMethod.POST, value = "/amap/ride/distinct")
    @ResponseBody
    @ApiImplicitParams({
            @ApiImplicitParam(name = "key",value = "高德apiKey",required = true,dataType = "string",defaultValue = "5b9e41e21963210d9b2216d56a45d93a"),
            @ApiImplicitParam(name = "sLat",value = "起点纬度",required = true),
            @ApiImplicitParam(name = "sLng",value = "起点经度",required = true),
            @ApiImplicitParam(name = "eLat",value = "终点纬度",required = true),
            @ApiImplicitParam(name = "eLng",value = "终点纬度",required = true),
    })
    public String ride_disticnt(String key, Double sLat, Double sLng, Double eLat, Double eLng) {
        String result = null;
        try {
            result = AMapUtils.getRideDistinct(key, sLat, sLng, eLat, eLng);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.errorResult("获取失败");
        }

        return AjaxResult.successResult(result);
    }

}
